package com.mbl.base.core.utils;

import com.mbl.base.config.security.SecurityUser;
import com.mbl.base.modular.member.entity.User;

public class FactoryUser {

    /**
     * 创建管理员对象
     * @param adminEntity
     * @return
     */
    public static SecurityUser createUser(com.mbl.base.modular.base.entity.Admin adminEntity){
        SecurityUser securityUser = new SecurityUser();
        securityUser.setPassword(adminEntity.getPassword());
        securityUser.setUsername(adminEntity.getUsername());
        securityUser.setId(adminEntity.getId());
        securityUser.setNickname(adminEntity.getRealName());
        securityUser.setAvatar(adminEntity.getAvatar());
        securityUser.setEnabled(true);
        return securityUser;
    }

    /**
     * 创建用户对象
     * @param user
     * @return
     */
    public static SecurityUser createUser(User user) {
        SecurityUser securityUser = new SecurityUser();
        securityUser.setPassword(user.getPassword());
        securityUser.setUsername(user.getUsername());
        securityUser.setNickname(user.getNickName());
        securityUser.setId(user.getId());
        securityUser.setAvatar(user.getAvatar());
        securityUser.setEnabled(true);
        securityUser.setType(2);
        securityUser.setIntegral(user.getIntegral());
        return securityUser;
    }
}
